package com.gorillalogic.scrummonkey.dms {
	import mx.collections.ArrayCollection;
	import com.adobe.fiber.core.model_internal;
	
	
	[RemoteClass(alias="ScrumDMS.Project")]
	public class Project extends _Super_Project {
		/** 
		 * DO NOT MODIFY THIS STATIC INITIALIZER - IT IS NECESSARY
		 * FOR PROPERLY SETTING UP THE REMOTE CLASS ALIAS FOR THIS CLASS
		 *
		 **/
		
		/**
		 * Calling this static function will initialize RemoteClass aliases
		 * for this value object as well as all of the value objects corresponding
		 * to entities associated to this value object's entity.  
		 */     
		public static function _initRemoteClassAlias() : void
		{
			_Super_Project.model_internal::initRemoteClassAliasSingle(com.gorillalogic.scrummonkey.dms.Project);
			_Super_Project.model_internal::initRemoteClassAliasAllRelated();
		}
		
		model_internal static function initRemoteClassAliasSingleChild() : void 
		{
			_Super_Project.model_internal::initRemoteClassAliasSingle(com.gorillalogic.scrummonkey.dms.Project);
		}
		
		{
			_Super_Project.model_internal::initRemoteClassAliasSingle(com.gorillalogic.scrummonkey.dms.Project);
		}
		/** 
		 * END OF DO NOT MODIFY SECTION
		 *
		 **/ 
		
		public function Project(name:String = null, description:String = null) {
			super();
			this.name = name;
			this.description = description;
			this.releases = new ArrayCollection();
			this.objectives = new ArrayCollection();
		}

		public function addRelease(release:Release):void {
			release.project = this;
			this.releases.addItem(release);
		}

		public function removeObjective(objective:Objective):void {
			objective.unassign(this);
		}	

		public function addObjective(objective:Objective):void {
			objective.assign(this);
		}
		
		public function getAllIterations():ArrayCollection {
			var v:ArrayCollection = new ArrayCollection();
			for each(var r:Release in this.releases) {
				v.addAll(r.iterations);
			}
			return v;
		}
	}
}